import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutterroom/pages/home/widgets/common_image.dart';
import 'package:flutterroom/pages/my/data/my_button_data.dart';

class MyButtonList extends StatelessWidget {
  Widget _myButton(FunctionButtonItem data, BuildContext context) {
    return InkWell(
      onTap: () {
        if (data.title == "看房记录") {
          print("你点个鸡儿");
        } else {
          data.onTapHandle(context);
        }
      },
      child: Center(
        child: Column(
          children: <Widget>[
            CommonImage(
              data.imageUri,
              width: 40,
            ),
            Padding(padding: EdgeInsets.all(2)),
            Text(
              data.title,
              style: TextStyle(fontSize: 13),
            )
          ],
        ),
      ),
    );
  }
//=>相当于{}
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(top: 8),
      child: Wrap(
          spacing: 1,
          runSpacing: 1,
          children: list
              .map((item) => Container(
                    child: _myButton(item, context),
                    width: ScreenUtil().setWidth(750) / 4 - 1,
                    height: 80,
                  ))
              .toList()),
    );
  }
}
